# -*- coding:utf-8 -*- 
import os
#from django.shortcuts import render_to_response
from google.appengine.ext.webapp import template
from model import *
import chardet
def render(name, data):
    temp = os.path.join(os.path.dirname(__file__), 'template', name)
    return template.render(temp, data)

def qdata(key,dbname):
    #qdb=exec(''.jion([dbname,'.all()'])
    pass

    
def code_data(tx):
        try:
            message_body=tx.encode('utf-8')
        except:
            nb_encode=chardet.detect(tx) 
            nb_code=nb_encode['encoding']
                #logging.info(nb_code)
            message_body=tx.decode(nb_code,'ignore').encode('utf-8')
        return unicode(message_body,'utf-8','ignore')
    